package com.zero.qth.controller;

import com.alibaba.fastjson2.JSONObject;
import com.zero.common.annotation.anonymous.Anonymous;
import com.zero.common.core.domain.result.AjaxResult;
import com.zero.qth.service.IPaymentService;
import com.zero.qth.weixin.config.WeixinPayConfig;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

/*
* 微信支付完成回调
* */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/notify")
public class NotifyController {

    private final WeixinPayConfig weixinPayConfig;
    private final IPaymentService paymentService;
//    @PostMapping("/weixin")
//    public String weixin(HttpServletRequest request) {
//
//        return "fail";
//    }

    @Anonymous
    @PostMapping("/refundOrder")
    public String weixinRefundNotify(@RequestBody JSONObject request) throws Exception {
        return paymentService.weixinRefundNotify(request);
    }
}
